﻿using FTBS.Models.BLO;
using FTBS.Models.Entities;
using FTBS.Models.Entities.Concert;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace FTBS.Controllers
{
    public class HomeController : Controller
    {
        private TheaterBLO _theaterBlo = new TheaterBLO();
        private HomeBLO _homeBlo = new HomeBLO();
        private ScheduleBLO _scheduleBlo = new ScheduleBLO();


        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Customer()
        {
            ////Send all theater to into HomePage
            //List<Theater> lstTheater = new List<Theater>();
            //lstTheater = _theaterBlo.GetAllTheaterInfo();
            //ViewBag.ListTheater = lstTheater;

            List<Film> listFilmPromotion = new List<Film>();
            listFilmPromotion = _scheduleBlo.GetFilmsPromotion();
            Film filmBestPromotion = new Film();
            filmBestPromotion = _scheduleBlo.GetFilmsBestPromtion();

            List<Film> list7FilmPromotion = new List<Film>();
            list7FilmPromotion.Add(filmBestPromotion);

            if (listFilmPromotion.Count >= 6)
            {
                for (int i = 0; i < 7; i++)
                {
                    list7FilmPromotion.Add(listFilmPromotion[i]);
                }
            }
            ViewBag.ListFilmPromotion = list7FilmPromotion;
            return View();
        }

        public PartialViewResult NearestTheater(string latitude, string longitude)
        {
            List<TheaterConcertEntity> listTheater = new List<TheaterConcertEntity>();
            double customerLatitude = Convert.ToDouble(latitude);
            double customerLongitude = Convert.ToDouble(longitude);
            listTheater = _homeBlo.GetListNearestTheater(latitude, longitude);

            return PartialView("NearestTheater", listTheater);
        }

        
    }
}
